<template>
    <div id="seven-root">
        <div id="seven">
            <p id="seven-p">名淘电商在线学习平台服务保障</p>
            <!-- 轮播图 -->
            <div id="container">
                <div 
                    class="swiper"
                    v-for="(s,i) in slide"
                    :key="i"
                    ref='swiper'
                >
                    <i>{{s.content}}</i>
                    <h3>{{s.recommend}}</h3>
                    <p class="box-p">{{s.promise}}</p>
                </div>
            </div>

            <!-- 左右箭头 -->
            <div id="arrow">
                <b class="direction" @click="prev">←</b>
                <span class="control"> 
                    <b class="index" style="font-size:25px;">{{currentIndex+1}}</b> 
                    <i style="font-size:40px;opacity: 0.4;">/</i>
                    <span class="length">{{slide.length}}</span>
                </span>
                <b class="direction" @click="next">→</b>
            </div>
        </div>
    </div>
</template>

<script>
  export default {
    data () {
        return {
            slide:[
                {
                    content:'名淘电商学院在线学习平台提供完善的直播课堂，所有学员均可在学习直播课程的过程中与讲师进行互动，讲师会在授课过程中安排特定时间对授课内容进行答疑解惑，方便学员对所学内容进行巩固加深。同时平台提供课程内容的视频回放服务。',
                    recommend:'直播课堂',
                    promise:'互动体验',
                },
                {
                    content:'名淘电商学院在线学习平台提供丰富的视频课程，所有学员在选择购买平台课程后，在课程的有效期内均可享受所有视频课程的体验服务，同时平台提供在线客服，为您解决学习中遇到的所有问题。',
                    recommend:'视频课程',
                    promise:'品质服务',
                },
                {
                    content:'名淘电商学院在线学习平台提供及时的课程更新服务，保障平台的课程内容与各个电商平台的规则升级保持一致，让学员学到的技能进入岗位即可用。',
                    recommend:'平台技术',
                    promise:'更新及时',
                },
            ],
            currentIndex:0,
        };
    },
    methods:{
        next(){
            this.$refs.swiper[this.currentIndex].classList.add('hide');
            this.currentIndex++;
            if(this.currentIndex>=this.slide.length-1){
                this.currentIndex = this.slide.length - 1;
            }
            this.$refs.swiper[this.currentIndex].classList.remove('hide');
        },
        prev(){
            this.$refs.swiper[this.currentIndex].classList.add('hide');
            this.currentIndex--;
            if(this.currentIndex<=0){
                this.currentIndex = 0;
            }
            this.$refs.swiper[this.currentIndex].classList.remove('hide');
        },
    },
    mounted(){
        let swiper = this.$refs.swiper;
        swiper.forEach(el => {
            el.classList.add('hide');
        });
        swiper[this.currentIndex].classList.remove('hide');
    }

  }

</script>
<style scoped>
#seven-root{
    height: 572px;
    background-image: url(/imgs/home/bj03.png);
    color: #ffffff;
}
#seven{
    width: 1200px;
    height: 100%;
    margin: 0 auto;
    padding-top: 100px;
}
#seven-p{
    width: 600px;
    font-size: 35px;
    color: #ffffff;
    margin: 0 auto;
    margin-bottom: 50px;
    font-weight: bold;
}
#container{
    width: 880px;
    height: 200px;
    margin: 0 auto;
    text-align: center;
    position: relative;
}
.swiper{
    width: 100%;
    height: 100%;
    flex-shrink: 0;
    position: absolute;
    left: 0;
    top: 0;
    transition: all 1s;
}
i{
    font-size: 22px;
    font-weight: 100;
    margin-bottom: 20px;
    display: inline-block;
}
.box-p{
    margin-top: -10px;
    font-size: 14px;
    opacity: 0.4;
}
#arrow{
    width: 150px;
    height: 100px;
    margin: 0 auto;
    padding-top: 30px;
    display: flex;
    justify-content: space-between;
}
.direction{
    width: 30px;
    font-size: 30px;
    transition: all 0.7s;
    cursor: pointer;
    user-select: none;
    -moz-user-select: none;
}
.direction:hover{
    color: rgb(33, 126, 211);
}
.control{
    position: relative;
    top: -10px;
}
.index{
    position: relative;
    top: -15px;
}
.length{
    position: relative;
    top: 5px;
    font-size: 20px;
    opacity: 0.4;
}
/* 隐藏 */
.hide{
    opacity: 0;
}
</style>